<?php
declare(strict_types=1);
/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://gitee.com/xmo/MineAdmin
 */
namespace Plugin\Alarm\Http\Request\Admin;

use Hyperf\Validation\Request\FormRequest;

/**
 * 报警事件回调验证数据类
 */
class RdAlarmMsgRequest extends FormRequest
{
    /**
     * 场景配置
     */
    protected array $scenes = [
        'index' => [
            'type', 'alarm_pic_path', 'alarm_pic_name', 'camera_id', 'camera_url', 
            'image_height', 'image_width', 'result_data', 'roi', 'src_pic_path', 
            'src_pic_name', 'task_id', 'timestamp', 'yj_data_id', 'device_serial', 
            'channel_no', 'msg_type', 'alarm_type', 'file_url'
        ],
        'create' => [
            'type', 'alarm_pic_path', 'alarm_pic_name', 'camera_id', 'camera_url', 
            'image_height', 'image_width', 'result_data', 'roi', 'src_pic_path', 
            'src_pic_name', 'task_id', 'timestamp', 'yj_data_id', 'device_serial', 
            'channel_no', 'msg_type', 'alarm_type', 'file_url'
        ],
        'update' => [
            'type', 'alarm_pic_path', 'alarm_pic_name', 'camera_id', 'camera_url', 
            'image_height', 'image_width', 'result_data', 'roi', 'src_pic_path', 
            'src_pic_name', 'task_id', 'timestamp', 'yj_data_id', 'device_serial', 
            'channel_no', 'msg_type', 'alarm_type', 'file_url'
        ],
        'delete' => [ 'id', 'ids' ],
    ];

    public function authorize(): bool
    {
        return true;
    }


    /**
     * 新增数据验证规则
     * return array
     */
    public function rules(): array
    {
        return [
            'id' => 'integer|min:1',
            'ids' => 'array|min:1',
            'ids.*' => 'integer|min:1',

            'type' => 'in:1,2',
            'alarm_pic_path' => 'nullable|string|max:255',
            'alarm_pic_name' => 'string|max:255',
            'camera_id' => 'integer|min:1',
            'camera_url' => 'string|max:255',
            'image_height' => 'integer|min:1',
            'image_width' => 'integer|min:1',
            'result_data' => 'array',
            'roi' => 'nullable|array',
            'src_pic_path' => 'nullable|string|max:255',
            'src_pic_name' => 'string|max:255',
            'task_id' => 'integer|min:0',
            'timestamp' => 'integer|min:0',
            'yj_data_id' => 'nullable|string|max:255',
            'device_serial' => 'nullable|string|max:255',
            'channel_no' => 'nullable|integer',
            'msg_type' => 'nullable|string',
            'alarm_type' => 'nullable|integer',
            'file_url' => 'nullable|string|max:255',
        ];
    }


    /**
     * 字段映射名称
     * return array
     */
    public function attributes(): array
    {
        return [
            'id' => 'ID',
            'type' => '报警类型1:雷达 2:相机',
            'alarm_pic_path' => '报警图片地址',
            'alarm_pic_name' => '报警图片名称',
            'camera_id' => '摄像头ID',
            'camera_url' => '摄像头地址',
            'image_height' => '图片高度',
            'image_width' => '图片宽度',
            'result_data' => '检测结果数据',
            'roi' => '感兴趣区域',
            'src_pic_path' => '源图片地址',
            'src_pic_name' => '源图片名称',
            'task_id' => '任务ID',
            'timestamp' => '时间戳',
            'yj_data_id' => '预警ID',
            'device_serial' => '设备序列号',
            'channel_no' => '通道号',
            'msg_type' => '消息类型',
            'alarm_type' => '报警类型',
            'file_url' => '文件地址',
        ];
    }

public function messages(): array
{
    return [
            'id.required' => 'ID必填',
            'type.required' => '报警类型必填',
            'alarm_pic_name.required' => '报警图片名称必填',
            'camera_id.required' => '摄像头ID必填',
            'camera_url.required' => '摄像头地址必填',
            'image_height.required' => '图片高度必填',
            'image_width.required' => '图片宽度必填',
            'result_data.required' => '检测结果数据必填',
            'src_pic_name.required' => '源图片名称必填',
            'task_id.required' => '任务ID必填',
            'timestamp.required' => '时间戳必填',
    ];
}
}